package org.pgis.gui;

import javax.swing.JColorChooser;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JLabel;

import org.pgis.core.AbstractScenePanel;

import java.awt.Font;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class LineDistancePanel extends JPanel{

	private static final long serialVersionUID = 1L;
	private AbstractScenePanel asp;
	public LineDistancePanel(AbstractScenePanel asp) {
		this.asp = asp;
		initialize();
	}

	private void initialize() {

		this.setLayout(null);

		JLabel labelColor = new JLabel("Line");
		labelColor.setFont(new Font("Century", Font.BOLD, 16));
		labelColor.setBounds(87, 11, 81, 30);
		this.add(labelColor);

		JButton buttonDelete = new JButton("Delete");
		buttonDelete.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				Color bgColor = JColorChooser.showDialog(null,
                        "Choose Background Color",
                        getBackground());
				if(bgColor != null) {
					asp.getSim().setColor(bgColor);
					asp.refresh();
				}
			}
		});
		buttonDelete.setBounds(10, 55, 106, 32);
		this.add(buttonDelete);

		JButton buttonDeleteAll = new JButton("Delete All");
		buttonDeleteAll.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Color bgColor = JColorChooser.showDialog(null,
			                                 "Choose Background Color",
			                                 getBackground());
				if(bgColor != null) {
					asp.setBackgroundColor(bgColor);
				}
			}
		});
		buttonDeleteAll.setBounds(126, 55, 106, 32);
		this.add(buttonDeleteAll);

		JLabel labelObjectColor = new JLabel("");
		labelObjectColor.setBackground(Color.BLACK);
		labelObjectColor.setBounds(126, 57, 40, 30);
		this.add(labelObjectColor);

		JLabel labelStart = new JLabel("Start");
		labelStart.setBounds(21, 110, 46, 14);
		add(labelStart);

		JLabel labelEnd = new JLabel("End");
		labelEnd.setBounds(21, 135, 46, 14);
		add(labelEnd);

		JLabel labelDistance = new JLabel("Distance");
		labelDistance.setBounds(21, 157, 46, 14);
		add(labelDistance);

		JLabel labelStartValue = new JLabel("");
		labelStartValue.setBounds(95, 110, 137, 14);
		add(labelStartValue);

		JLabel labelEndValue = new JLabel("");
		labelEndValue.setBounds(95, 135, 137, 14);
		add(labelEndValue);

		JLabel labelDistanceValue = new JLabel("");
		labelDistanceValue.setBounds(95, 157, 137, 14);
		add(labelDistanceValue);
	}
}
